package com.example.work2

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class MessageFragment : Fragment() {
    private val msgList=ArrayList<Msg>()
    private var adapter:MessageAdapter?=null
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState:Bundle?): View? {
        val view =  inflater.inflate(R.layout.message_fragment,container,false)
        initMSG()
        val wc=view.findViewById(R.id.messageView) as RecyclerView
        val layoutManager=LinearLayoutManager(activity)
        wc.layoutManager=layoutManager
        adapter= MessageAdapter(msgList)
        wc.adapter=adapter
        return view
    }
    private fun initMSG(){
        msgList.add(Msg("jake",R.mipmap.jake,"15:00","开摆就完事了"))
        msgList.add(Msg("tim",R.mipmap.jana,"13:30","看我打不打你就完事了"))
        msgList.add(Msg("james",R.mipmap.jude,"13:20","哈哈哈啊哈哈哈啊哈哈哈"))
        msgList.add(Msg("schmoes",R.mipmap.schmoes,"12:00","真是天才啊你"))
        msgList.add(Msg("jazebelle",R.mipmap.jazebelle,"11:00","我到了你在那里？"))
        msgList.add(Msg("jai",R.mipmap.jai,"10:40","借下B站大会员"))
    }
}